Conventionally, to save the space on a memory/hard disk and to shorten the time taken to write data on it, not only a digital multifunctional peripheral but also image processing apparatuses such as a digital camera and a facsimile apparatus compress color image data, which allows for reduction in cost and a gain in speed. A JPEG scheme that uses discrete cosine transformation and a scheme that uses wavelet transformation are widely employed as color still image compression schemes. Encoding schemes of these kinds generally encode an image for each predetermined block (for example, for each unit of 8×8 or 16×16 pixels), and perform discrete cosine transformation, quantization, and entropy coding, thereby achieving high compression efficiency. In these schemes, variable-length coding for each block is adopted, so random access for referring to a small area is difficult. In this access, the code length is indeterminate depending on the type of image, so the position (memory address) of a block to be decoded is also indeterminate. This makes it necessary not only to determine this position in some way but also to perform decoding processing for each block. Also, discrete cosine transformation by JPEG normally requires 8×8 pixels as the block size. To perform discrete cosine transformation which uses this block unit at high speed, not only a high-speed arithmetic unit and dedicated hardware but also a buffer memory is necessary. An image compression technique (for example, Japanese Patent Laid-Open No. 2004-104621) which uses a small block size and a fixed compression ratio has been disclosed as an approach to solving these problems associated with the random access performance and the complexity of processing.
Also, with an increase in resolution, the number of pixels which require image processing is dramatically increasing, so the processing load is getting heavier. When the above-mentioned image compression is employed, processing of decoding compressed data becomes necessary to refer to and convert the pixel data having undergone this image compression. In other words, image processing cannot be performed for compressed data intact, so its decoding processing inevitably becomes necessary. This makes it necessary to process all pixels in high-resolution data for each pixel, thus prolonging the processing time. As techniques of compressing pixel data without encoding it, a known run length encoding scheme of storing pixel data and their run lengths, and a technique (for example, Japanese Patent Laid-Open No. 10-257488) of compressing pixel data by detecting an edge for each block and storing two colors of this edge have been disclosed.
In the JPEG scheme which uses discrete cosine transformation and the scheme which uses wavelet transformation, a large amount of calculation is required for each block, so the processing time prolongs and expensive processing hardware must be used. Also, decoding processing inevitably becomes necessary upon image processing for compressed data, so the processing time considerably prolongs, depending on the number of pixels to be processed. For example, high-resolution data is not always necessary depending on the purpose of use of the image data, and therefore must be reduced to low-resolution data. That is, to generate low-resolution data from high-resolution data having undergone compression coding by, for example, JPEG, decoding processing and special reduction processing inevitably become necessary.
A case in which color-reduction and lossy compression are performed in a compression scheme (for example, the above-mentioned run length encoding scheme) of performing image compression by holding only matching information with an adjacent pixel without holding each pixel value of an image will be considered. If some pixels have similar colors in the run length encoding scheme, the use of a lossy run length encoding scheme of regarding these pixels as having the same color and counting and encoding the length of a run of these pixels may propagate the color difference from the original to a plurality of pixels, leading to image deterioration. This deterioration is not limited to the run length encoding scheme and is a common problem when compression and color-reduction processing using matching information with an adjacent pixel are combined.